package com.lbs.jiepiaisi.view;

import android.app.ProgressDialog;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;

import com.lbs.jiepiaisi.R;

/**
 *
 * 时间：2019/12/02 10:34
 * 作用：等待
 */
public class LoadingDialog extends ProgressDialog {

    private TextView titleTextView;

    private Context mContext;

    public LoadingDialog(Context context)
    {
        super(context);
    }

    public LoadingDialog(Context context, int theme)
    {
        super(context, theme);
    }

    /** 设置提示内容.进度*/
    public void setContent(String title) {
        if (title == null) return;
        titleTextView.setText(title);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.loading_dialog);
        //设置不可取消，点击其他区域不能取消，实际中可以抽出去封装供外包设置
        setCancelable(false);
        setCanceledOnTouchOutside(false);

        titleTextView = findViewById(R.id.tv_title);

        WindowManager.LayoutParams params = getWindow().getAttributes();
        params.width = WindowManager.LayoutParams.WRAP_CONTENT;
        params.height = WindowManager.LayoutParams.WRAP_CONTENT;
        getWindow().setAttributes(params);
    }

    public void show(String title) {
        super.show();
        if (title == null)
            return;
        titleTextView.setText(title);
    }

}

